#include <cstdio>
using namespace std;

const int N = 1000001;
int n, m, p;
int cnt[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef DEBUG
	freopen("T1.in", "r", stdin);
	freopen("T1.out", "w", stdout);
#endif
#endif
	scanf("%d%d%d", &n, &m, &p);
	int tmp = 0, tmp2 = 0;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &tmp);
		for (int j = 1; j <= tmp; ++j) {
			scanf("%d", &tmp2);
			cnt[tmp2]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; ++i) {
		if (cnt[i] == p) {
			ans++;
		}
	}
	printf("%d\n", ans);
	for (int i = 1; i <= m; ++i) {
		if (cnt[i] == p) {
			printf("%d ", i);
		}
	}
	return 0;
}